import { Component, Input, OnInit } from '@angular/core';
import { AppGlobalService } from 'src/app/shared/service/app-global.service';
import { HttpService } from 'src/app/shared/service/http.service';
import { PageModalService } from 'src/app/shared/service/page-modal-service';
@Component({
  selector: 'app-daily-clean-list',
  templateUrl: './daily-clean-list.component.html',
  styleUrls: ['./daily-clean-list.component.scss'],
})
export class DailyCleanListComponent implements OnInit {
  @Input() tagData: any;
  constructor(
    private pageModalService: PageModalService,
    private http: HttpService,
    private appGlobalService: AppGlobalService,
  ) { }

  ngOnInit() {
  }

  beforeSubmit(link, submit) {
    if (submit) {  // 如果有submit
      const params = {
        content: submit.content,
        id: submit.id,
        sessionId: localStorage.getItem('sessionId')
      };
      this.http.post('application/submit', params, res => {
        // 请求成功
        if (res.success) {
          this.pageModalService.openPage(link);
        } else {
          // 请求数据失败
          this.appGlobalService.showToast(res.message, 2000, 'middle');
        }
      });
    } else {
      this.pageModalService.openPage(link);
    }
  }
}